﻿/*** This script will only run if the version number in the database is less than 01.80.00 ***/
if((SELECT REPLACE(VersionNumber,'.','') FROM Version) < '018000')
BEGIN

	/** Update Version **/
	DELETE FROM Version
	INSERT INTO Version(VersionNumber) VALUES (N'01.80.00')
	
		IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS
	WHERE TABLE_NAME = 'SilverlightDesktopUsers' AND COLUMN_NAME = 'SilverlightKey')
	
	BEGIN
		ALTER TABLE dbo.SilverlightDesktopUsers
		DROP COLUMN SilverlightKey
	END
	
	IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS
	WHERE TABLE_NAME = 'SilverlightDesktopUsers' AND COLUMN_NAME = 'SilverlightPassword')
	BEGIN
		ALTER TABLE dbo.SilverlightDesktopUsers ADD
	    SilverlightPassword nvarchar(150) NULL
	END	
	
END